﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC_DaLatServices.Models;

namespace MVC_DaLatServices.Controllers
{
    public class BatDongSanController : Controller
    {
        private DaLatServiceEntities db = new DaLatServiceEntities();

        //
        // GET: /BatDongSan/

        public ActionResult Index()
        {
            ViewBag.articles = db.Articles.Include(a => a.Category).Include(a => a.ArticleFrontPage);
            ViewData["Menu"] = db.Categories.ToList();
            return View(db.ArticleFrontPages.ToList());
        }
        //
        // GET:/BatDongSan/BanDat
        public ActionResult BanDat()
        {
            ViewData["Menu"] = db.Categories.ToList();
            return View();
        }
        //
        // GET: /GiaiTri/Details/5

        public ActionResult Details(int id = 0)
        {
            ViewData["Menu"] = db.Categories.ToList();
            Article article = db.Articles.Find(id);
            if (article == null)
            {
                return HttpNotFound();
            }
            return View(article);
        }

        ////
        //// GET: /GiaiTri/Create

        //public ActionResult Create()
        //{
        //    ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name");
        //    ViewBag.ArticleID = new SelectList(db.ArticleFrontPages, "ArticleID", "ArticleID");
        //    return View();
        //}

        ////
        //// POST: /GiaiTri/Create

        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Create(Article article)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Articles.Add(article);
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }

        //    ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", article.CategoryID);
        //    ViewBag.ArticleID = new SelectList(db.ArticleFrontPages, "ArticleID", "ArticleID", article.ArticleID);
        //    return View(article);
        //}

        ////
        //// GET: /GiaiTri/Edit/5

        //public ActionResult Edit(int id = 0)
        //{
        //    Article article = db.Articles.Find(id);
        //    if (article == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", article.CategoryID);
        //    ViewBag.ArticleID = new SelectList(db.ArticleFrontPages, "ArticleID", "ArticleID", article.ArticleID);
        //    return View(article);
        //}

        ////
        //// POST: /GiaiTri/Edit/5

        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit(Article article)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Entry(article).State = EntityState.Modified;
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }
        //    ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", article.CategoryID);
        //    ViewBag.ArticleID = new SelectList(db.ArticleFrontPages, "ArticleID", "ArticleID", article.ArticleID);
        //    return View(article);
        //}

        ////
        //// GET: /GiaiTri/Delete/5

        //public ActionResult Delete(int id = 0)
        //{
        //    Article article = db.Articles.Find(id);
        //    if (article == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(article);
        //}

        ////
        //// POST: /GiaiTri/Delete/5

        //[HttpPost, ActionName("Delete")]
        //[ValidateAntiForgeryToken]
        //public ActionResult DeleteConfirmed(int id)
        //{
        //    Article article = db.Articles.Find(id);
        //    db.Articles.Remove(article);
        //    db.SaveChanges();
        //    return RedirectToAction("Index");
        //}

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}